package com.example.syyao.myapp;

import android.content.Intent;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.CardView;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.syyao.myapp.Personal.Personal_heart;
import com.example.syyao.myapp.Pot.Pot_content;

public class FindFragment extends Fragment {
    public ImageView backhome;

    //获取罐子
    //顶层罐子
    public ImageView pot_hot;
    public ImageView pot_love;

    //热门罐子
    public CardView pot_hot_1;
    public CardView pot_hot_2;
    public CardView pot_hot_3;

    //更多罐子
    public CardView pot_more_1;
    public CardView pot_more_2;
    public CardView pot_more_3;
    public CardView pot_more_4;
    public CardView pot_more_5;
    public CardView pot_more_6;
    public CardView pot_more_7;
    public CardView pot_more_8;
    public CardView pot_more_9;

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_find, container, false);

        pot_hot=view.findViewById(R.id.pot_hot);
        pot_love=view.findViewById(R.id.pot_love);

        pot_hot_1=view.findViewById(R.id.pot_hot_1);
        pot_hot_2=view.findViewById(R.id.pot_hot_2);
        pot_hot_3=view.findViewById(R.id.pot_hot_3);

        pot_more_1=view.findViewById(R.id.pot_more_1);
        pot_more_2=view.findViewById(R.id.pot_more_2);
        pot_more_3=view.findViewById(R.id.pot_more_3);
        pot_more_4=view.findViewById(R.id.pot_more_4);
        pot_more_5=view.findViewById(R.id.pot_more_5);
        pot_more_6=view.findViewById(R.id.pot_more_6);


        //绑定监听者
//        pot_hot.setOnClickListener(new pot_lis());
//        pot_love.setOnClickListener(new pot_lis());

        pot_hot_1.setOnClickListener(new pot_lis1());
        pot_hot_2.setOnClickListener(new pot_lis2());
        pot_hot_3.setOnClickListener(new pot_lis3());

        pot_more_1.setOnClickListener(new pot_lis4());
        pot_more_2.setOnClickListener(new pot_lis5());
        pot_more_3.setOnClickListener(new pot_lis6());
        pot_more_4.setOnClickListener(new pot_lis7());
        pot_more_5.setOnClickListener(new pot_lis8());
        pot_more_6.setOnClickListener(new pot_lis9());


        backhome=view.findViewById(R.id.pot_back_home);
        backhome.setOnClickListener(new pot_back());
        return view;
    }

    public class pot_lis1  implements View.OnClickListener {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), Pot_content.class);
            intent.putExtra("kind","汪汪");
            startActivity(intent);
        }
    }
    public class pot_lis2  implements View.OnClickListener {

        @Override
        public void onClick(View v) {

            Intent intent = new Intent(getActivity(), Pot_content.class);
            intent.putExtra("kind","小坏坏");
            startActivity(intent);
        }
    }
    public class pot_lis3  implements View.OnClickListener {

        @Override
        public void onClick(View v) {

            Intent intent = new Intent(getActivity(), Pot_content.class);
            intent.putExtra("kind","假的");
            startActivity(intent);
        }
    }
    public class pot_lis4  implements View.OnClickListener {

        @Override
        public void onClick(View v) {

            Intent intent = new Intent(getActivity(), Pot_content.class);
            intent.putExtra("kind","小仓鼠");
            startActivity(intent);
        }
    }
    public class pot_lis5  implements View.OnClickListener {

        @Override
        public void onClick(View v) {

            Intent intent = new Intent(getActivity(), Pot_content.class);
            intent.putExtra("kind","滑稽");
            startActivity(intent);
        }
    }
    public class pot_lis6  implements View.OnClickListener {

        @Override
        public void onClick(View v) {

            Intent intent = new Intent(getActivity(), Pot_content.class);
            intent.putExtra("kind","咸鱼");
            startActivity(intent);
        }
    }
    public class pot_lis7  implements View.OnClickListener {

        @Override
        public void onClick(View v) {

            Intent intent = new Intent(getActivity(), Pot_content.class);
            intent.putExtra("kind","熊猫");
            startActivity(intent);
        }
    }
    public class pot_lis8  implements View.OnClickListener {

        @Override
        public void onClick(View v) {

            Intent intent = new Intent(getActivity(), Pot_content.class);
            intent.putExtra("kind","蘑菇头");
            startActivity(intent);
        }
    }
    public class pot_lis9  implements View.OnClickListener {

        @Override
        public void onClick(View v) {

            Intent intent = new Intent(getActivity(), Pot_content.class);
            intent.putExtra("kind","可达鸭");
            startActivity(intent);
        }
    }

    public class pot_back implements View.OnClickListener{

        @Override
        public void onClick(View v) {
            final MainActivity mainActivity = (MainActivity) getActivity();
            mainActivity.setFragmentSkipInterface(new MainActivity.FragmentSkipInterface() {
                @Override
                public void gotoFragment(ViewPager viewPager) {
                    /** 跳转到第零个页面的逻辑 */
                    viewPager.setCurrentItem(1);
                }
            });
            /** 进行跳转 */
            mainActivity.skipToFragment();
        }
    }
}
